package com.woniuxy.sm.service.impl;

import com.woniuxy.sm.bean.User;
import com.woniuxy.sm.bean.Users;
import com.woniuxy.sm.mapper.UsersMapper;
import com.woniuxy.sm.service.UsersService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 实现类交给容器管理
 */
@Service
public class UsersServiceImpl implements UsersService{

    /**
     * 注入持久层对象不
     */
    @Resource
    private UsersMapper usersMapper;

    //查询用户
    @Override
    public List<Users> findUser() {
        return usersMapper.findUser();
    }
    //查看是否查询到用户
    @Override
    public Users findUserName(String str) {
        return usersMapper.findUserName(str);
    }

    //查看是否查询到用户
    @Override
    public boolean findName(String str) {
        if(usersMapper.findUserName(str) == null) {
            return false;
        }
        return true;
    }
    //添加用户
    @Override
    public void addUser(User user) {
        usersMapper.addUser(user);
        //提交事务
       /* sqlSession.commit();*/
    }
    //查询用户
    @Override
    public User findByName(String str) {
        return usersMapper.findByName(str);
    }
    @Override
    public void updatePassword(int id, String str) {
        usersMapper.updatePassword(id, str);
        //提交事务
      /*  sqlSession.commit();*/
    }


}
